import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

import { AdminComponent } from './admin.component';
import { AdminUserComponent } from './admin-user.component';
import { AdminMenuComponent } from './admin-menu.component';
import { AdminDashboardComponent } from './admin-dashboard.component';

import { AuthGuard } from '../auth-guard.service';

const routes: Routes = [
    {
        path: '', component: AdminComponent,
        canActivate: [AuthGuard],
        children: [
            {
                path: '',
                canActivateChild: [AuthGuard],
                children: [
                    { path: 'user', component: AdminUserComponent },
                    { path: 'menu', component: AdminMenuComponent },
                    { path: '', component: AdminDashboardComponent }
                ]
            }
        ]
    },
];

@NgModule({
    imports: [RouterModule.forChild(routes)],
    exports: [RouterModule],
})
export class AdminRoutingModule { }

export const routedComponents = [AdminComponent, AdminUserComponent, AdminMenuComponent, AdminDashboardComponent];